<template>
  <div class="space">
    <AlNavBar @onClickLeft="back" title="space" :show-go-home="true"></AlNavBar>

    <div class="app-list">

      <AppBlock
          v-for="(item,index) in appList"
          :key="index"
          :title="item.name"
          :img-src="item.imgSrc"
          :to="item.to"
      >
      </AppBlock>
    </div>
  </div>
</template>

<script>
import AlNavBar from "@/components/AlNavBar";
import AppBlock from "@/components/AppBlock";
import {space} from "@/api/home";

export default {
  name: "space",
  components: {AlNavBar, AppBlock},
  data() {
    return {
      appList: []
    }
  },
  created() {
    space().then(res=>{
      console.log(res)
      console.log(res.data)
      this.appList = res.data.appList;
    })
  },
  methods: {
    back() {
      if (this.$route.query.redirect) {
        this.$router.push('/find')
      } else {
        // 正常跳转的
        this.$router.push('/home')
      }
    }
  }
}
</script>

<style lang="less" scoped>

.space {
  .app-list {
    margin-top: 20px;
  }
}
</style>